import request from '@/router/axios';

export const getRolesTree = (userId) => {
  return request({
    url: `/api/role/roleTreeListByUserId/${userId}`,
    method: 'post'
  })
}

export const setMenu = (data) => {
  return request({
    url: '/api/role/setAuthority',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      ...data
    }
  })
}
export const getListdata = (page, size, params) => {
  return request({
    url: '/api/role/list',
    method: 'post',
    params: {
      ...params,
      page,
      size,
    }
  })
}
export const remove = (roleId) => {
  return request({
    url: '/api/role/remove',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      roleId,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/role/add',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      ...row
    }
  })
}

export const update = (row) => {
  return request({
    url: '/api/role/edit',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const getRole = (roleId) => {
  return request({
    url: `/api/role/view/${roleId}`,
    method: 'get',
  })
}